#include<stdio.h>
int main()
{
        int num=0;
	int count=0;
	char ch;
	while((ch=getchar())!=EOF)
	{
		if(ch=='{')
		{
			count++;
		}
		else if(ch=='}'&&count>0)
		{
			count--;	
		}
                else if(ch=='}'&&count<=0)
                {
                      printf("No(-1)");
                      return 0;
                }
              
	}
        
	if(count==0)
	{
		printf("Yes");
	}
	else if(count>0)
	{
		printf("No(%d)",count);
	}
       
	return 0;
}
